import {Component, Inject} from '@angular/core';
import {FormBuilder, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
import {MatButton} from "@angular/material/button";
import {
  MAT_DIALOG_DATA,
  MatDialogActions,
  MatDialogClose,
  MatDialogContent,
  MatDialogTitle
} from "@angular/material/dialog";
import {MatFormField, MatLabel} from "@angular/material/form-field";
import {MatInput} from "@angular/material/input";
import {Instance} from "../../models/instance";

@Component({
  selector: 'app-instance-update',
  standalone: true,
    imports: [
        FormsModule,
        MatButton,
        MatDialogActions,
        MatDialogClose,
        MatDialogContent,
        MatDialogTitle,
        MatFormField,
        MatInput,
        MatLabel,
        ReactiveFormsModule
    ],
  templateUrl: './instance-update.component.html',
  styleUrl: './instance-update.component.scss'
})
export class InstanceUpdateComponent {
  constructor(private fb: FormBuilder,
              @Inject(MAT_DIALOG_DATA) public data: Instance) {
  }
  instanceFB = this.fb.group({
    id: [this.data.id, Validators.required],
    instance_name: [this.data.instance_name, Validators.required],
    instance_describe: [this.data.instance_describe, Validators.required],
    address: [this.data.address, Validators.required],
    port: [this.data.port, Validators.required],
    username: [this.data.username, Validators.required],
    password: ['', Validators.required],
    cnf_file: [this.data.cnf_file, Validators.required],
    data_dir: [this.data.data_dir, Validators.required],
  });
}
